package it.cqupt.Controller;

import it.cqupt.bean.Student;
import it.cqupt.service.StudentService;
import it.cqupt.service.impl.StudentServiceImpl;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

public class StudentController {
    StudentService studentService = new StudentServiceImpl();
    @Test
    public void selectAll(){
        List<Student> students = studentService.selectAll();
        for(Student stu : students){
            System.out.println(stu);
        }
    }
    @Test
    public void selectById(){
        System.out.println(studentService.selectById(1));
    }

    @Test
    public void insertIntoStu(){
        Student stu = new Student(5,"锤锤",31);
        int res =studentService.insertToStu(stu);
        if(res!=0) System.out.println("添加成功");
    }
    @Test
    public void updateAllById(){
        Student stu = new Student(5,"锤锤的爸爸",55);
        int res =studentService.updateAllById(stu);
        if(res!=0) System.out.println("添加成功");
        Arrays.sort(new int[]{222});
    }

    @Test
    public void deleteStuById(){
        int i = studentService.deleteById(5);
        System.out.println(i!=0?"删除成功":"删除失败");
    }
}
